package com.sinopec.basemodule.api

import com.sinopec.basemodule.http.HttpParamObj
import com.sinopec.basemodule.http.api.HttpResult
import com.sinopec.basemodule.http.api.RetroAPIFactory
import com.sinopec.basemodule.model.*
import io.reactivex.Observable

/**
 * @author lwj
 * @ClassName: Api
 * @Description: 所有的APi层
 */
object BaseModuleApi {
    private val iService: BaseModuleService by lazy {
        RetroAPIFactory.create(BaseModuleService::class.java)
    }

    /*---------------------------------------入库模块start---------------------------------------*/
    /**
     * 入库-列表页面
     */
    fun stockInList(machineCode: String): Observable<HttpResult<List<StockInListModel>?>?>? {
        val hashMap = HttpParamObj.createParams()
            .putParam("machineCode", machineCode)//单据唯一标识
            .end()
        return iService.stockInList(hashMap)
    }


    /**
     * 确认入库-编码校验
     */
    fun confirmStockIn(model: StockInApiRequestModel): Observable<HttpResult<List<ErrorPalletCodeResultModel>?>?>? {
        val hashMap = HttpParamObj.createParams()
            .putParam("taskRecordId", model.taskRecordId)//单据唯一标识
            .putParam("palletCodes", model.palletCodes)//托盘编码集合
            .end()
        return iService.confirmStockIn(hashMap)
    }


    /**
     * 确认入库完成
     */
    fun confirmStockInOrderFinish(outboundIntegrationId: Long): Observable<HttpResult<Any?>?>? {
        val end = HttpParamObj.createParams()
            .putParam("taskRecordId", outboundIntegrationId)//单据唯一标识
            .end()
        return iService.confirmStockInOrderFinish(end)
    }
    /*---------------------------------------入库模块end---------------------------------------*/

    /*---------------------------------------出库模块start---------------------------------------*/
    /**
     * 出库-列表页面
     */
    fun stockOutList(machineCode: String): Observable<HttpResult<List<StockOutListModel>?>?>? {
        val hashMap = HttpParamObj.createParams()
            .putParam("machineCode", machineCode)//单据唯一标识
            .end()
        return iService.stockOutList(hashMap)
    }


    /**
     * 确认出库-编码校验
     */
    fun confirmStockOut(model: StockOutApiRequestModel): Observable<HttpResult<List<ErrorPalletCodeResultModel>?>?>? {
        val hashMap = HttpParamObj.createParams()
            .putParam("outboundIntegrationId", model.outboundIntegrationId)//单据唯一标识
            .putParam("palletCodes", model.palletCodes)//托盘编码集合
            .end()
        return iService.confirmStockOut(hashMap)
    }


    /**
     * 确认出库完成
     */
    fun confirmStockOutOrderFinish(outboundIntegrationId: Long): Observable<HttpResult<Any?>?>? {
        val end = HttpParamObj.createParams()
            .putParam("outboundIntegrationId", outboundIntegrationId)//单据唯一标识
            .end()
        return iService.confirmStockOutOrderFinish(end)
    }
    /*---------------------------------------出库模块end---------------------------------------*/
    /*---------------------------------------盘库模块start---------------------------------------*/

    /**
     * 日常盘点-获取包装规格列表
     */
    fun getPackSpecsType(): Observable<HttpResult<List<PackSpecsTypeModel>?>?>? {
        val hashMap = HttpParamObj.createParams()
            .end()
        return iService.getPackSpecsType(hashMap)
    }

    /**
     * 确认日常盘点-编码校验
     */
    fun confirmDailyInventory(model: DailyInventoryApiRequestModel): Observable<HttpResult<Any?>?>? {
        val hashMap = HttpParamObj.createParams()
            .putParam("packSpecsTypeId", model.packSpecsTypeId)//包装规格id
            .putParam("palletCodes", model.palletCodes)//托盘编码集合
            .end()
        return iService.confirmDailyInventory(hashMap)
    }

    /*---------------------------------------盘库模块end---------------------------------------*/
}